# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=grabber
pkgver=0.1
pkgrel=11
groups=('blackarch' 'blackarch-webapp')
pkgdesc='A web application scanner. Basically it detects some kind of vulnerabilities in your website.'
arch=('any')
url='http://rgaucher.info/beta/grabber/'
license=('BSD')
depends=('python')
makedepends=('dos2unix')
source=('http://rgaucher.info/beta/grabber/Grabber.zip')
sha512sums=('aa8ffed715dbcee735b7188ba3334fcf130a36f5a82bb088a6071888830e052f3696017f33563cca8259d460c2721a39aa89b738afe8704b869d69455a909b9d')

prepare() {
  cd Grabber

  # Fix line endings.
  dos2unix *

  # Fix log file location.
  sed -i "s|LogHandler('grabber.log')|LogHandler(os.getenv('HOME') + '/.grabber.log')|" grabber.py
}

package() {
  cd Grabber

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp --no-preserve=ownership -r * "$pkgdir/usr/share/$pkgname/"

  rm "$pkgdir/usr/share/$pkgname/setup.py"

  cat > "$pkgdir/usr/bin/grabber-scanner" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/grabber-scanner"
}

